home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved */
- /*****************************************************************************/
- /* This source-code is NOT public domain nor Freeware, this is part of */
- /* 'The C Programming Package' which is Shareware. */
- /* If you use this code, please register and get a free Full-VGA version */
- /*****************************************************************************/
- /*----------------*
- * CPPLMEN2.C *
- * Menu manager2 *
- *----------------*/
-
- /* Included Files */
- # include <stdio.h>
- # include <io.h>
- # include <dos.h>
- # include <fcntl.h>
- # include <bios.h>
- # include <stdlib.h>
- # include <conio.h>
-
- /* Global Variables */
- extern int bm,i,j,k,l,m,n,t,x,x1,x2,xm,y,y1,y2,ym,z,menu0,menu2,return1;
- extern int colour1,colour2,colour3,colour4,colour5,returning;
- extern unsigned char c0,c1,trashcan[];
-
- /*----------------------*
- * CHOICE DISPLAY HELP2 *
- *----------------------*/
- void choice_display_help2()
- {
- /* We display the help that concerns the line on */
- /* which is the menu cursor (in red). */
- if(menu2==1){
- /* */
- display_help("MENU2 ",16,2,1); restore_help_screen();
- }
- if(menu2==2){
- /* */
- display_help("MENU2 ",17,3,1); restore_help_screen();
- }
- if(menu2==3){
- /* */
- display_help("MENU2 ",18,4,1); restore_help_screen();
- }
- if(menu2==4){
- /* */
- display_help("MENU2 ",19,5,1); restore_help_screen();
- }
- if(menu2==5){
- /* */
- display_help("MENU2 ",20,6,1); restore_help_screen();
- }
- if(menu2==6){
- /* */
- display_help("MENU2 ",21,7,1); restore_help_screen();
- }
- if(menu2==7){
- /* available */
- display_help("MENU2 ",22,8,1); restore_help_screen();
- }
- if(menu2==8){
- /* */
- display_help("MENU2 ",23,9,1); restore_help_screen();
- }
- if(menu2==9){
- /* */
- display_help("MENU2 ",24,10,1); restore_help_screen();
- }
- if(menu2==10){
- /* */
- display_help("MENU2 ",25,11,1); restore_help_screen();
- }
- }
- /*----------------*
- * GET THE MOUSE2 *
- *----------------*/
- int get_the_mouse2()
- {
- /* If we choose with the mouse */
- /* Only available for menu 1 */
- if(ym==1){
- /* We clicked on the first line, certainly */
- /* To change of menu. */
- x=get_the_mouse0();
- menu0=x; return(-2);
- }
- if((xm>8)&&(xm<25)){
- if(ym==3){
- /* */
- menu2=1; return(1);
- }
- if(ym==4){
- /* */
- menu2=2; return(1);
- }
- if(ym==5){
- /* */
- menu2=3; return(1);
- }
- if(ym==6){
- /* */
- menu2=4; return(1);
- }
- if(ym==7){
- /* */
- menu2=5; return(1);
- }
- if(ym==8){
- /* */
- menu2=6; return(1);
- }
- if(ym==9){
- /* */
- menu2=7; return(1);
- }
- if(ym==10){
- /* */
- menu2=8; return(1);
- }
- if(ym==11){
- /* */
- menu2=9; return(1);
- }
- if(ym==12){
- /* */
- menu2=10; return(1);
- }
- }
- /* If we clicked outside the menu zone */
- /* we want to erase the menu and return to menu 0 */
-
- menu0=0; return(-2);
- }
- /*--------------*
- * MENU CHOICE2 *
- *--------------*/
- int menu_choice2()
- {
- returning=wait_for_a_key();
- /* Else we pressed a keyboard key */
- /* Cf CPPLTC2.C for the keyboard test and the returned codes */
- if(returning==-1){
- /* <Esc> we want to go back to menu0 */
- menu0=0; return(-2);
- }
- if(returning==40){
- /* <Enter> execute the command */
- return(1);
- }
- if(returning==100){
- /* We pressed a mouse button */
- m=get_the_mouse2(); return(m);
- }
- /* The key letters depends on the menu */
-
- /* So the below returns need to be modified */
- if(returning==24){
- /* <O> <o> */
- menu2=1; return(1);
- }
- if(returning==23){
- /* <N> <n> */
- menu2=2; return(1);
- }
- if(returning==28){
- /* <S> <s> */
- menu2=3; return(1);
- }
- if(returning==13){
- /* <D> <d> */
- menu2=5; return(1);
- }
- if(returning==27){
- /* <R> <r> */
- menu2=6; return(1);
- }
- if(returning==18){
- /* <I> <i> */
- menu2=7; return(1);
- }
- if(returning==15){
- /* <F> <f> */
- menu2=8; return(1);
- }
- if(returning==26){
- /* <Q> <q> */
- menu2=10; return(1);
- }
- /* For the 2-bytes coded keys, this is the second byte */
- if(returning==59){
- /* Function key <F1> = help */
- return(59);
- }
- if(returning>100){
- /* We pressed Alt + another key to get a menu */
- c1=returning-100; k=get_special_menu00();
- if(k>0) return(-2);
- }
- if((returning==77)||(returning==75)){
- /* Left or Right arrow to change of menu */
- c1=returning; k=get_special_menu00();
- if(k>0) return(-2);
- }
- if(returning==72){
- /* Up arrow */
- if(menu2>1) menu2--;
- else menu2=10;
- return(0);
- }
- if(returning==80){
- /* Down arrow */
- if(menu2<10) menu2++;
- else menu2=1;
- return(0);
- }
- /* Else we return 0 = no choice */
- return(0);
- }
- /*-----------------------*
- * DISPLAY LINE OF menu2 *
- *-----------------------*/
- void display_menu_line2()
- {
- /* First we display the chosen menu0 */
- textattr(colour5);
- gotoxy(9,1); cputs(" Menu2 ");
- /* Same thing for the selected line */
- if(menu2==1){
- gotoxy(9,3); cputs(" ");
- }
- if(menu2==2){
- gotoxy(9,4); cputs(" ");
- }
- if(menu2==3){
- gotoxy(9,5); cputs(" ");
- }
- if(menu2==4){
- gotoxy(9,6); cputs(" ");
- }
- if(menu2==5){
- gotoxy(9,7); cputs(" ");
- }
- if(menu2==6){
- gotoxy(9,8); cputs(" ");
- }
- if(menu2==7){
- gotoxy(9,9); cputs(" ");
- }
- if(menu2==8){
- gotoxy(9,10); cputs(" ");
- }
- if(menu2==9){
- gotoxy(9,11); cputs(" ");
- }
- if(menu2==10){
- gotoxy(9,12); cputs(" ");
- }
- }
- /*----------------------*
- * DISPLAY KEY LETTER 2 *
- *----------------------*/
- void display_key_letter2()
- {
- textattr(116);
- gotoxy(10,3); cputs(" ");
- gotoxy(10,4); cputs(" ");
- gotoxy(10,5); cputs(" ");
- gotoxy(10,6); cputs(" ");
- gotoxy(10,7); cputs(" ");
- gotoxy(10,8); cputs(" ");
- gotoxy(10,9); cputs(" ");
- gotoxy(10,10); cputs(" ");
- gotoxy(10,11); cputs(" ");
- gotoxy(10,12); cputs(" ");
- }
- /*---------------*
- * DISPLAY menu2 *
- *---------------*/
- void display_menu2()
- {
- /* To avoid the trace of the previous mouse position */
- /* we hide it during the display, */
- /* and show it when the line has been displayed. */
- hide_the_mouse(); textattr(colour2);
- gotoxy(7,2); cputs(" ┌────────────────┐ ");
- gotoxy(7,3); cputs(" │ │ ");
- gotoxy(7,4); cputs(" │ │ ");
- gotoxy(7,5); cputs(" │ │ ");
- gotoxy(7,6); cputs(" │ │ ");
- gotoxy(7,7); cputs(" │ │ ");
- gotoxy(7,8); cputs(" │ │ ");
- gotoxy(7,9); cputs(" │ │ ");
- gotoxy(7,10); cputs(" │ │ ");
- gotoxy(7,11); cputs(" │ │ ");
- gotoxy(7,12); cputs(" │ │ ");
- gotoxy(7,13); cputs(" └────────────────┘ ");
- display_key_letter2(); display_menu_line2();
- show_the_mouse();
- }
- /*----------------*
- * MENU MANAGER 2 *
- *----------------*/
- int menu_manager2()
- {
- restore_screen(); return1=0;
- while(1){
- display_menu2(); return1=menu_choice2();
- if(return1==-2) return(-2);
- if(return1==-1) return(-1);
- if(return1==59) choice_display_help2();
- display_menu2();
- if(return1==1){
- /* We execute the selected function */
- if(menu2==10){
- /* We want to quit the sub-program */
- return(-1);
- }
- if(menu2==1){
- /* */
-
- }
- if(menu2==2){
- /* */
-
- }
- if(menu2==3){
- /* */
-
- }
- if(menu2==4){
- /* */
-
- }
- if(menu2==5){
- /* */
-
- }
- if(menu2==6){
- /* */
-
- }
- if(menu2==7){
- /* */
-
- }
- if(menu2==8){
- /* */
-
- }
- if(menu2==9){
- /* */
-
- }
- }
- }
- }
- /* End of the Module *//*----------------*/
-